<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on March 6, 2009 at 4:30:39 pm</time-stamp>


<class>
<name>ItemTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.ItemTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.ItemTest</class-id>
<body>A test class for the SUnit testing the Item class

Instance Variables:
	i1	&lt;Item&gt;	An item

</body>
</comment>

<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">setUp
 "Create test objects.  This is called before every individual test"
	 i1 := Item named: 'Video Game' sku:'89X999'.</body>

<body package="SupplyChain" selector="testItemNeedsReorder">testItemNeedsReorder
   i1 reorderPoint: 10.
   i1 quantity: 15.
   self deny: i1 needsReorder.
   i1 quantity: 9.
   self assert: i1 needsReorder.</body>

<body package="SupplyChain" selector="testItemPotentialProfit">testItemPotentialProfit
   i1 buyPrice: 10.
   i1 sellPrice: 35.
   i1 quantity: 3.
   self assert: i1 potentialProfit = 75.</body>

<body package="SupplyChain" selector="testItemPrintString">testItemPrintString
   i1 quantity: 10.
   self assert: i1 printString = '10 Video Game 89X999'.</body>

<body package="SupplyChain" selector="testItemProfit">testItemProfit
   i1 buyPrice: 10.
   i1 sellPrice: 35.
   self assert: i1 profit = 25.</body>

<body package="SupplyChain" selector="testItemValue">testItemValue
   self setUpPrices.
   self assert: i1 itemValue = 24.</body>
</methods>

<methods>
<class-id>SupplyChain.ItemTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	i1 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.</body>
</methods>

</st-source>
